package com.stox.services.core.subscription;

import java.util.HashSet;
import java.util.Set;

import com.stox.client.api.core.WebSocketClient;
import com.stox.shared.core.model.intf.Callback;

public class SubscriptionManager {

	public static final SubscriptionManager INSTANCE = new SubscriptionManager();
	private final Set<Callback<String,Boolean>> publishers = new HashSet<>();

	private SubscriptionManager() {
		publishers.add(BarPublisher.INSTANCE);
	}
	
	public void sendMessage(String message){
		WebSocketClient.INSTANCE.onMessage(message);
	}
	
	public void onMessage(String message){
		for(Callback<String,Boolean> publisher : publishers){
			publisher.execute(message);
		}
	}
	
}
